package com.example.dog.core.controller;

import com.example.dog.core.entity.Dog;
import com.example.dog.core.service.DogService;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PathVariable;

@Controller
@Slf4j
public class DogController {
    @GetMapping("getDog")
    public Dog getDog(){
        log.debug("开始查询");
        Dog dog = new Dog();
        log.debug("结束查询");
//        Optional<Dog> dogOptional = null;
//        try {
//            dogOptional = Optional.of(dog);
//        }catch (Exception e){
//            log.error(e.getMessage());
//        }
        return dog;
    }
    @Autowired
    private DogService dogService;
    @GetMapping("getDogById/{id}")
    public Dog getDogById(@PathVariable("id") String id){
        log.debug("开始查询");
        Dog dog = dogService.getById(id);
        log.debug("结束查询");
//        Optional<Dog> dogOptional = null;
//        try {
//            dogOptional = Optional.of(dog);
//        }catch (Exception e){
//            log.error(e.getMessage());
//        }
        return dog;
    }
}
